﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using TCC.DTO;

namespace TCC
{
    public partial class Login : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void LoginButton_Click(object sender, EventArgs e)
        {
            var usr = new DtoUsuario
                            {
                                Nome = idUsuario.Text,
                                Senha = idSenha.Text
                            };

            var daUsr = new DB.DA.DaUsuario();

            var mp = (MasterPage.MPage)this.Master;

            if (daUsr.ValidaLogin(usr))
            {
                mp.Usuario = usr;
                Response.Redirect("generic.aspx");
            }

            mp.Usuario = null;
            lblMsg.Text = "Usuário/Senha inválido(s).";
        }

    }
}